﻿/*
 * Created by SharpDevelop.
 * User: IEscarro
 * Date: 8/25/2009
 * Time: 9:50 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using Miming.Model;

namespace Miming.Gui
{
	/// <summary>
	/// Description of UserListForm.
	/// </summary>
	public partial class UserListForm : BaseForm
	{
		public UserListForm()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
		}
		
		[System.ComponentModel.EditorBrowsableAttribute()]
		protected override void OnActivated(EventArgs e)
		{
			base.OnActivated(e);
			Model = SessionFacade.FindAllUsers();
		}
		
		protected override void OnModelChanged(EventArgs e)
		{
			base.OnModelChanged(e);
			listBox1.Items.Clear();
			foreach (User u in Model as IList<User>) {
				listBox1.Items.Add(u.Name);
			}
		}
		
		void ButtonCloseClick(object sender, EventArgs e)
		{
			Close();
		}
		
		void ButtonAddClick(object sender, EventArgs e)
		{
			MainForm.Instance.AddDialog(new UserForm());
		}
	}
}
